package com.foreknow.elm.controller;

import com.foreknow.elm.po.User;
import com.foreknow.elm.service.Impl.UserServiceImpl;
import com.foreknow.elm.service.UserService;

import javax.servlet.http.HttpServletRequest;

public class UserController {
    public Object getUserByIdByPass(HttpServletRequest request) {
        UserService userService=new UserServiceImpl();
        String phone=request.getParameter("phone");
        String password=request.getParameter("password");
        User user=userService.getUserByIdByPass(phone,password);
        return user;
    }

    public Object getUserById(HttpServletRequest request) {
        UserService userService=new UserServiceImpl();
        String userId=request.getParameter("userId");
        int i=userService.getUserById(userId);
        return i;
    }

    public Object saveUser(HttpServletRequest request){
        UserService us=new UserServiceImpl();
        String userId=request.getParameter("userId");
        String password=request.getParameter("password");
        String userName=request.getParameter("userName");
        int userSex=Integer.parseInt(request.getParameter("userSex"));
        int i=us.saveUser(userId,password,userName,userSex);
        return i;
    }
}
